package com.uqbar.pacman.imageComponents;

import java.util.ArrayList;

import com.uqbar.pacman.scenes.PacmanScene;
import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.appearances.Animation;
import com.uqbar.vainilla.appearances.Sprite;

public class PacmanSkin extends GameComponent<PacmanScene> {

	private Animation animation;
	private Sprite[] spsup = new Sprite[4];
	private Sprite[] spsrt = new Sprite[4];
	private Sprite[] spsdo = new Sprite[4];
	private Sprite[] spslf = new Sprite[4];
	private ArrayList<Sprite[]> animations = new ArrayList<Sprite[]>();

	
	
	public ArrayList<Sprite[]> getAnimations() {
		return animations;
	}

	public void setAnimations(ArrayList<Sprite[]> animations) {
		this.animations = animations;
	}

	public Animation getAnimation() {
		return animation;
	}

	public void setAnimation(Animation animation) {
		this.animation = animation;
	}
	
	public void setOrientation(int n){
		this.getAnimation().setSprites(this.getAnimations().get(n));
	}
	
	public PacmanSkin(double x,double y){
		Sprite p0 = Sprite.fromImage("/pacman0.png").scale(0.47);
		Sprite p1 = Sprite.fromImage("/pacman1.png").scale(0.47);
		Sprite p2 = Sprite.fromImage("/pacman2.png").scale(0.47);

		spsrt[0] = p2;
		spsrt[1] = p1;
		spsrt[2] = p0;
		spsrt[3] = p0;
		
		spsup[0] = p2.rotate(4.8);
		spsup[1] = p1.rotate(4.8);
		spsup[2] = p0.rotate(4.8);
		spsup[3] = p0.rotate(4.8);
		
		spsdo[0] = p2.rotate(1.5);
		spsdo[1] = p1.rotate(1.5);
		spsdo[2] = p0.rotate(1.5);
		spsdo[3] = p0.rotate(1.5);
		
		spslf[0] = p2.rotate(3.2);
		spslf[1] = p1.rotate(3.2);
		spslf[2] = p0.rotate(3.2);
		spslf[3] = p0.rotate(3.2);
		
		this.getAnimations().add(spsup);
		this.getAnimations().add(spsrt);
		this.getAnimations().add(spsdo);
		this.getAnimations().add(spslf);
		

		this.setX(x);
		this.setY(y);
		this.setAnimation(new Animation(0.07,this.getAnimations().get(3)));
		this.setAppearance(this.getAnimation());
	}
}
